package org.splink.deepsplink.boot {
	import suites.stub.DeeplinkStrategyStub;

	import org.splink.deepsplink.config.ConfigData;
	import org.splink.deepsplink.config.PageData;
	import org.splink.library.tree.INode;
	import org.splink.library.tree.Node;
	import org.splink.library.tree.Tree;

	/**
	 * Uses a <code>MockDeeplinkStrategy</code> to avoid asyc tests
	 * 
	 * @author Max Kugland
	 */
	public class TestBootstrapper {
		public function TestBootstrapper(config : ConfigData, strategy : IBootStrategy) {
			var tree : Tree = new Tree(new Node(config.pageData.id, config.pageData.clone()));
			toTree(tree.root, config.pageData);
			var facade : DeepsplinkFacade = new DeepsplinkFacade(tree, config, new DeeplinkStrategyStub());
			strategy.boot(facade);
			facade.start();
		}

		private static function toTree(parent : INode, data : PageData) : void {
			for each (var pd : PageData in data.pageDataArray) {
				var node : INode = new Node(pd.id, pd.clone());
				parent.add(node);
				toTree(node, pd);
			}
		}
	}
}